#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/12/27 20:21
# @Author  : Sun
# @File    : modify_family_note.py
# @Software: PyCharm
import json

import requests

from common.read_yaml import ReadYaml
from common.write_log import WriteLog


class CreateSns:
    _URL = ReadYaml().read_yaml().get('domain') + "/relation/sns/createSns"
    _DATA = {
        "name": "张三的歌",
        "icon": "http://partyimage.oss.jjbisai.com/2021/11/b3cc982283a04ae0922a0c1e87d7b2e3.jpg",
        "note": "阿拉蕾"
    }
    _HEADERS = {
        'platform': 'RN',
        'authorization': None,
        'Content-Type': 'application/json;charset=utf-8'
    }

    def create_sns(self, JJUid, name=None):
        self._DATA['name'] = name
        # self._HEADERS['authorization'] = GetFamilyToken(
        # ).get_token(JJUid=JJUid)
        self._HEADERS['authorization'] = ReadYaml().read_yaml(file_path="./config/family_token.yaml").get(JJUid)
        r = requests.request(
            data=json.dumps(
                self._DATA),
            method='POST',
            url=self._URL,
            headers=self._HEADERS)
        result = json.dumps(r.json(), ensure_ascii=False, indent=4)
        WriteLog().write_log().info(result)
        return result


if __name__ == '__main__':
    # ModifyFamilyNote().modify_family_note(JJUid=106146203, dwPidOut=20000686)
    # 管理员 106146624
    CreateSns().create_sns(JJUid=106146624)
